package com.viser.partyinrs.adapters;

import java.util.Vector;

import com.viser.partyinrs.http.HttpDispatcher;

public class LoginAdapter extends DataAdapter{
	
	public LoginAdapter()
	{
		dispatcher=new HttpDispatcher();
	}
	
	public boolean logIn(String username, String password)
	{
		try
		{
			Vector<String> postParameters = new Vector<String>();
			postParameters.add("email="+username);
			postParameters.add("pass="+password);
			String httpResponse = 
				dispatcher.getHttpResponse_POST(pageBase+"prijava.php", postParameters);
			if(httpResponse.equals("1"))
				return true;
			else return false;
		}
		catch(Exception ex)
		{
			return false;
		}
	}
	
	public boolean registracija(String ime,String prezime,String email, String pass)
	{
		boolean rezultat=false;
		
		try {
			Vector<String> postParameters = new Vector<String>();
			postParameters.add("email="+email);
			postParameters.add("pass="+pass);
			postParameters.add("ime="+ime);
			postParameters.add("prezime="+prezime);
			
			String httpResponse = dispatcher.getHttpResponse_POST(
					pageBase+"registracija.php", postParameters);
			if(httpResponse.trim().equals("1"))
				rezultat=true;
			else rezultat=false;
		} catch (Exception e) {
			rezultat = false;
		}
		return rezultat;
	}
}
